package com.tmxk.employee.servlet;

import com.tmxk.employee.service.TScheduleService;
import com.tmxk.employee.service.impl.TScheduleServiceImpl;
import org.apache.log4j.Logger;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "TScheduleDeleteServlet",urlPatterns = {"/TScheduleDeleteServlet"})
public class TScheduleDeleteServlet extends HttpServlet {
    private Logger logger = Logger.getLogger(TScheduleDeleteServlet.class);
    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 设置request、response字符编码格式,解决中文乱码
        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");
        response.setCharacterEncoding("utf-8");
        // 获取前端传递的行程数据参数
        String tScheduleId = request.getParameter("tScheduleId");

        //创建业务层访问对象
        TScheduleService scheduleService = new TScheduleServiceImpl();
        boolean isDel = scheduleService.deleteSchedule(tScheduleId);
        //将添加是否成功的结果响应给前端
        response.getWriter().println(isDel);
        logger.info("isDel:" + isDel);
    }
}
